<?php
Class checkIfLink{

	protected $pageextension = array('htm','html','xhtml','shtml','shtm','asp','aspx','cfm','php','php3','php4','php5','jsp','jst','java','vbs');
    protected $imageextension = array('gif','jpg','jpeg','png','tif','tiff');

        static function is_mailto($link){
		$protocol = substr($link,0,7);
		if ($protocol == "mailto:"){ return true;}
		else{return false;}
	}

	static function is_http($link){
		$protocol = substr($link,0,7);
		if ($protocol == "http://"){ return true;}
		else{return false;}
	}

	static function is_https($link){
		$protocol = substr($link,0,8);
		if ($protocol == "https://"){ return true;}
		else{return false;}
	}
	
	static function is_anchor($link){
		$protocol = substr($link,0,1);
		if ($protocol == "#"){ return true;}
		else{return false;}	
	}
	
	static function is_javascript($link){
		$protocol = substr($link,0,10);
		if ($protocol == "javascript:"){ return true;}
		else{return false;}	
	}

	static function is_page($page){
		$page = strtolower($page);
		//$extension = substr($page,-5);
                $location_dot = strpos($page,".");
                if(!$location_dot == "false"){
                $extension = substr($page,$location_dot,4);
                }
                else{
                  $extension = $page;  

                }
		$findhtm = stripos($extension,"htm");
		$findphp = stripos($extension,"php");
		$findaspx = stripos($extension,"aspx");
		$checkforslash = substr($page,-1);
		if($checkforslash == "/"){ 
			
			$findfolder = true;
		}
		else{
			
			$findfolder = false;
		}
		if($findhtm === false and $findphp === false and $findaspx === false and $findfolder === false){return false;}
		else{return true;}
	}
	
	static function is_php($page){
		$extentsion = substr($page,-3);
		if ($extension == 'php'){return true;}else{return false;}
	}
	
	static function is_asp($page){
		$extentsion = substr($page,-3);
		if ($extension == 'asp'){return true;}else{return false;}
	}
	
	static function is_html($page){
		$extension = substr($page,-5);
		if (stripos($extension,"htm")){return true;}else{return false;}
	}
	
	
	static function is_image($link){
		$link = strtolower($link);
		$extension = substr($link,-5);
		$findgif = strpos($extension,"gif");
		$findjpg = strpos($extension,"jpg");
		$findjpeg = strpos($extension,"jpeg");
		$findpng = strpos($extension,"png");
		unset($link);
		if($findgif=== false and $findjpg===false and $findjpeg===false and $findpng===false){ return false;}
		else{return true;}
	}
    
    static function is_swf($link){
    	$link = strtolower($link);
        $extension = substr($link,-4);
        $findswf = strpos($extension,"swf");
        if($findswf === false){return false;}
        else{return true;}
    }
}
?>